snapshot: Use a better placeholder
authorMatthias Clasen <mclasen@redhat.com>
Mon, 9 Oct 2017 02:19:22 +0000 (22:19 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 9 Oct 2017 02:19:22 +0000 (22:19 -0400)
An empty container has the same effect as transparency
with the cairo renderer, but creates black with Vulkan.
To avoid this, explicitly use a transparent color node.

This fixes the css blendmode example in gtk4-demo with
the Vulkan renderer.

gtk/gtksnapshot.c

index 5d2a7f18f6de21ea48b3ff38cc845411996a8c04..2f72614443d4f1661e2b2082ca9c502a638aeb1b 100644 (file)
@@ -746,15 +746,18 @@ gtk_snapshot_collect_blend_top (GtkSnapshot      *snapshot,
                                 const char       *name)
 {
   GskRenderNode *bottom_node, *top_node, *blend_node;
+  GdkRGBA transparent = { 0, 0, 0, 0 };
 
   top_node = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes, name);
   bottom_node = state->data.blend.bottom_node;
 
+  g_assert (top_node != NULL || bottom_node != NULL);
+
   /* XXX: Is this necessary? Do we need a NULL node? */
   if (top_node == NULL)
-    top_node = gsk_container_node_new (NULL, 0);
+    top_node = gsk_color_node_new (&transparent, &bottom_node->bounds);
   if (bottom_node == NULL)
-    bottom_node = gsk_container_node_new (NULL, 0);
+    bottom_node = gsk_color_node_new (&transparent, &top_node->bounds);
 
   blend_node = gsk_blend_node_new (bottom_node, top_node, state->data.blend.blend_mode);
   gsk_render_node_set_name (blend_node, name);